#include "Main.h"

#include <inttypes.h>
#include "GlobalDefinitions.h"
#include "ADC.h"
#include "DIM230.h"
#include "WaterTemp.h"
#include "RTC.h"
#include "LM75.h"
#include "ComProtocol.h"
#include "FanRpm.h"
#include "IO.h"
#include "FanPwm.h"

extern volatile RTC_date_struct RTC_date;
extern uint8_t LM75_temps[NR_LM75_SENSORS];



static void HighLevelDriver_init(void)
{
	data_init();

	uart_init(UART_BAUD_SELECT(UART_BAUDRATE, F_CPU));

	//LM75_init();

	//RTC_init();

	IO_init();

	FanPwm_init();

	FanRpm_init();

//	ADC_init();

	DIM230_init();

	sei();

}


	// check if start up time is now
	//RTC_checkSut();




int main(void)
{
	HighLevelDriver_init();
	while (1)
	{
		DIM230_calcValues();
	//	IO_update();
		FANPWM_upadate();
		CalcRpm();

	}
}
void data_init()
{
 	s_data.fanpwm_ch0 = 100;
	s_data.ledpwm_ch0 = 1;
	s_data.ledpwm_ch1 = 1;
	s_data.ledpwm_ch2 = 1;
	s_data.ledpwm_ch3 = 1;
	s_data.dimm_ch0 = 0;
	s_data.dimm_ch1 = 0;
	s_data.dimm_ch2 = 0;
    s_data.tempair_t0 = 20;
    s_data.tempair_t1 = 25;
    s_data.tempair_t2 = 30;
    s_data.tempair_t3 = 35;
    s_data.tempair_t4 = 40;
    s_data.tempair_t5 = 45;
    s_data.tempair_t6 = 50;
    s_data.tempair_t7 = 60;
    s_data.tempwater_t0 = 20;
    s_data.tempwater_t1 = 35;
	s_data.fanrpm_v0 = 1200;
	s_data.fanrpm_v1 = 1200;
	s_data.fanrpm_v2 = 1200;
	s_data.fanrpm_v3 = 1200;
	s_data.io = 0;
	s_data.relay = 0;

}


